@extends('user._layouts.default')

@section('css')
    {{HTML::style('user/css/base.css')}}
@stop

@section('user-main')
<div style="font-size: 25px;">{{{$title or ''}}}<a href="{{URL::to('user/links')}}" class="am-btn am-fr am-btn-xs am-btn-primary">友情链接</a></div>
<hr/>

  <h2>{{$sub_title}}</h2>
  @if(Session::has('message'))
      <div class="am-alert am-alert-{{Session::get('message')['type']}} am-margin am-text-center" data-am-alert>{{Session::get('message')['content']}}</div>
  @endif
  @if($errors->has())
      <div class="am-alert am-alert-danger am-margin am-text-center" data-am-alert>{{$errors->first()}}</div>
  @endif
  {{Form::model($one,array('url'=>'user/links/doadd','method'=>'post','class'=>'am-form am-form-horizontal am-margin-top-lg'))}}


  <div class="am-form-group">
    {{Form::label('name','链接名称',array('class'=>'am-u-sm-2 am-form-label'))}}
    <div class="am-u-sm-10">
      {{Form::text('name')}}
    </div>
  </div>

  <div class="am-form-group">
    {{Form::label('url','链接地址',array('class'=>'am-u-sm-2 am-form-label'))}}
    <div class="am-u-sm-10">
      {{Form::text('url')}}
    </div>
  </div>
  <div class="am-form-group">
    {{Form::label('sort_order','排序',array('class'=>'am-u-sm-2 am-form-label'))}}
    <div class="am-u-sm-10">
      {{Form::text('sort_order')}}
    </div>
  </div>
  <div class="am-form-group">
    <div class="am-u-sm-10 am-u-sm-offset-2">
      {{Form::hidden('id')}}
      {{Form::submit('提交',array('class'=>'am-btn am-btn-primary'))}}
    </div>
  </div>
{{Form::close()}}

<hr/>
<h2>链接列表</h2>
@if($links)
<table class="am-table am-table-bordered am-table-striped am-table-hover">
    <thead>
        <tr>
            <th>链接名称</th>
            <th>链接地址</th>
            <th>排序</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
    	@foreach($links as $link)
        <tr>
            <td>{{$link->name}}</td>
            <td>{{$link->url}}</td>
            <td>{{$link->sort_order}}</td>
            <td><a href="{{$link->url}}" class="am-btn am-btn-primary am-btn-xs ">访问</a><a href="{{URL::to('user/links/'.$link->id)}}" class="am-btn am-btn-primary am-btn-xs am-margin-left-sm">修改</a><a href="{{URL::to('user/links/delete/'.$link->id)}}" class="am-btn am-btn-danger am-btn-xs am-margin-left-sm">删除</a></td>
        </tr>
        @endForeach
    </tbody>
</table>
@endIf
@stop
<!--[if (gte IE 9)|!(IE)]><!-->
@section('js')

@stop
